import AdAgent from "./AdAgent";
import { BannerLocation } from "./AdManager";
import PlatUtils from "./PlatUtils";

const { ccclass, property } = cc._decorator;

@ccclass
export default class AdAgentNative extends AdAgent {

    private _className: string = "com.yzxx.jni.JNIHelper";

    public Init() {

    }

    public ShowBanner(location: BannerLocation) {
        if (PlatUtils.IsNativeAndroid) {
            cc.log("AdAgentNative ShowBanner");
            try {
                jsb.reflection.callStaticMethod(this._className, "showAd", "(Ljava/lang/String;)V",location);
            } catch (error) {
                cc.log(error);
            }
        }
    }

    public HideBanner(location: BannerLocation) {

    }

    public ShowInterstitial() {
        if (PlatUtils.IsNativeAndroid) {
            cc.log("AdAgentNative ShowInterstitial");
            try {
                jsb.reflection.callStaticMethod(this._className, "showAd", "(Ljava/lang/String;)V","Interstitial");
            } catch (error) {
                cc.log(error);
            }
        }
    }

    public GameExit() {
        if (PlatUtils.IsNativeAndroid) {
            cc.log("AdAgentNative GameExit");
            try {
                jsb.reflection.callStaticMethod(this._className, "gameExit", "()V");
            } catch (error) {
                cc.log(error);
            }
        }
    }

}
